package com.orhon.smartcampus.modules.base.fetcher;


import com.orhon.smartcampus.modules.base.dao.DictionaryDao;
import com.orhon.smartcampus.modules.base.entity.Dictionary;
import com.orhon.smartcampus.modules.base.gqlModel.GQLDictionary;
import com.orhon.smartcampus.modules.base.mm.DictionaryMapper;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class DictionaryFetcher implements DataFetcher {

    @Autowired
    DictionaryDao dictionaryDao;
    
    @Override
    public Object get(DataFetchingEnvironment env) throws Exception {
        int id = Integer.parseInt(env.getArgument("id").toString());

        String hql = "from Dictionary where deleted_at = null and id = "+id;
        Dictionary item = dictionaryDao.findId(hql, null);
        if(item!=null) {
            GQLDictionary dictionary = DictionaryMapper.MAPPER.toDictionary(item);     
            return dictionary;
        }
		return null;
        
    }


}
